/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.unipar.cursoweb.service;

import br.com.unipar.cursoweb.modelo.Servico;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

/**
 *
 * @author Thiago
 */

@Service("servicoService")
public class ServicoServiceImpl extends GenericServiceImpl<Servico> implements ServicoService {

    @Override
    public List<Servico> consultar(String nome) {
        Criteria crit = ((Session) entityManager.getDelegate()).createCriteria(Servico.class);
        if (nome != null) {
            crit.add(Restrictions.ilike("nome", nome, MatchMode.ANYWHERE));
        }

        return crit.list();
    }
}
